<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:element name="Pipeline" type="PipelineType" />

    <xsd:complexType name="PipelineType">
        <xsd:choice>
            <xsd:element name="Writer" type="WriterType" />
            <xsd:element name="Reader" type="ReaderType" />
            <xsd:element name="Filter" type="FilterType" />
            <xsd:element name="MultiFilter" type="MultiFilterType" />
        </xsd:choice>
        <xsd:attribute name="type" type="xsd:string" use="required" />
    </xsd:complexType>

    <xsd:complexType name="TypeAndOptionsType">
        <xsd:sequence>
            <xsd:element name="Option" type="OptionType" minOccurs="0" maxOccurs="unbounded" />
        </xsd:sequence>
        <xsd:attribute name="type" type="xsd:string" use="required" />
    </xsd:complexType>

    <xsd:complexType name="OptionType" mixed="true">
        <xsd:attribute name="name" type="xsd:string" use="required" />
    </xsd:complexType>

    <xsd:complexType name="StageType">
        <xsd:complexContent>
            <xsd:extension base="TypeAndOptionsType" />
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="WriterType">
        <xsd:complexContent>
            <xsd:extension base="TypeAndOptionsType">
                <xsd:choice>
                    <xsd:element name="Reader" type="ReaderType" />
                    <xsd:element name="Filter" type="FilterType" />
                    <xsd:element name="MultiFilter" type="MultiFilterType" />
                </xsd:choice>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="ReaderType">
        <xsd:complexContent>
            <xsd:extension base="StageType" />
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="FilterType">
        <xsd:complexContent>
            <xsd:extension base="StageType">
                <xsd:choice>
                    <xsd:element name="Reader" type="ReaderType" />
                    <xsd:element name="Filter" type="FilterType" />
                    <xsd:element name="MultiFilter" type="MultiFilterType" />
                </xsd:choice>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="MultiFilterType">
        <xsd:complexContent>
            <xsd:extension base="StageType">
                <xsd:choice maxOccurs="unbounded">
                    <xsd:element name="Reader" type="ReaderType" />
                    <xsd:element name="Filter" type="FilterType" />
                    <xsd:element name="MultiFilter" type="MultiFilterType" />
                </xsd:choice>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    
</xsd:schema>
